import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: jingziyou
 * Date: 2023-03-02
 * Time: 21:19
 */
public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        int min = 99999999;
        for (int i = 0; i <= n - m; i++) {
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += arr[i + j];
            }
            if (min > sum)
                min = sum;
        }
        System.out.println(min);
    }
}
